package com.hpjpw.idoapp.service;

import com.hpjpw.ido.domain.Resume;
import com.hpjpw.ido.domain.ResumeReceived;
import com.hpjpw.ido.service.IResumeService;
import com.hpjpw.ido.service.IResumeReceivedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class IDoResumeService {
    @Autowired
    IResumeService resumeService;
    @Autowired
    IResumeReceivedService resumeReceivedService;

    public List<Map<String,String>> getResumeList(Resume resume){
        /* 实际返回的列表 */
        List<Map<String, String>> listReturn = new ArrayList<>();
        List<Resume> resumeList = resumeService.selectResumeList(resume);
        for(Resume item : resumeList){
            Map<String,String> map = new HashMap<>();
            map.put("resumeId",item.getId().toString());
            map.put("userId",item.getuId().toString());
            map.put("name",item.getName().toString());
            map.put("selfPicture",item.getSelfPicture().toString());
            map.put("phone",item.getPhone().toString());
            map.put("email",item.getEmail().toString());
            map.put("purpose",item.getPurpose().toString());
            map.put("selfIntroduction",item.getSelfIntroduction().toString());
            map.put("honor",item.getHonor().toString());
            map.put("experience",item.getExperience().toString());
            map.put("resumePath",item.getResumePath().toString());
            listReturn.add(map);
        }
        return listReturn;
    }

    public List<Map<String,String>> getResumeReceivedList(ResumeReceived resumeReceived){
        /* 实际返回的列表 */
        List<Map<String, String>> listReturn = new ArrayList<>();
        List<ResumeReceived> resumeList = resumeReceivedService.selectResumeReceivedList(resumeReceived);
        for(ResumeReceived item : resumeList){
            Map<String,String> map = new HashMap<>();
            map.put("resumeReceivedId",item.getId().toString());
            map.put("applyId",item.getApplyId().toString());
            map.put("enterpriseId",item.getEnterpriseId().toString());
            map.put("resumeId",item.getResumeId().toString());
            map.put("Date",item.getTime().toString());
            map.put("State",item.getState().toString());
            listReturn.add(map);
        }
        return listReturn;
    }

    /**
     * 获取某个用户的简历列表
     * @param u_Id
     * @return ResumeList
     */
    public List<Map<String,String>> personnalResumeList(Long u_Id){
        /* 实际返回的列表 */
        List<Map<String, String>> listReturn = new ArrayList<>();
        /*获取简历列表*/
        Resume resume = new Resume();
        resume.setuId(u_Id);
        listReturn = getResumeList(resume);
        return listReturn;
    }

    /**
     * 获取投递某公司的用户的简历列表
     * @param
     * @return ResumeList
     */
    public List<Map<String,String>> allResumes(Long enterpriseId){
        /* 实际返回的列表 */
        List<Map<String, String>> listReturn = new ArrayList<>();
        /*获取简历列表*/
        ResumeReceived resumeReceived = new ResumeReceived();
        resumeReceived.setEnterpriseId(enterpriseId);
        listReturn = getResumeReceivedList(resumeReceived);
        return listReturn;
    }


}
